package com.epam.cdp.selenium2.core.test.google;

import com.epam.cdp.selenium2.core.results.logger.Logger;
import com.epam.cdp.selenium2.core.ui.Browser;
import com.epam.cdp.selenium2.core.ui.Screen;
import com.epam.cdp.selenium2.core.ui.elements.Element;
import com.epam.cdp.selenium2.core.ui.elements.Input;

/**
 * @author akhachaturan
 * 
 */
public class GoogleScreen extends Screen
{

  private static final String TEST_LINK = "http://google.com";

  private Input searchInput = new Input( fromMap( "searchInput" ) );

  private Element searchButton = new Element( fromMap( "searchButton" ) );

  public static GoogleScreen open()
  {
    Logger.info( "Open " + TEST_LINK );
    Browser.getBrowser().get( TEST_LINK );
    return new GoogleScreen();
  }

  public void searchQuery( String query )
  {
    searchInput.typeValue( query );
    searchInput.clearInput();
    searchInput.typeValue( query );
    searchButton.click();
  }

  public void iAmLucky()
  {
    String[] composite = {"btnI"};
    new Element( byXpattern( "i_am_f", composite ) ).click();
  }
}
